<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ include file="../include/admincontent.jsp" %>
<style>
    .laytable-cell-1-sel {
        overflow: inherit;
    }
    .layui-table-cell {            overflow: inherit !important;         }
    /* 使得下拉框与单元格刚好合适 */
    td .layui-form-select{
        margin-top: -10px;
        margin-left: -15px;
        margin-right: -15px;
    }

    .table-select-icon{position:absolute;right:10px;line-height:34px;color:#d3d3d3}
    .table-select-selected dl{display:block}
    .table-select dl{position:absolute;left:0;padding:5px 0;z-index:999;min-width:100%;border:1px solid #d2d2d2;max-height:300px;
        overflow-y:auto;background-color:#fff;border-radius:2px;box-shadow:0 2px 4px rgba(0,0,0,.12);box-sizing:border-box}
    .table-select dl dd{cursor:pointer}
    .table-select dl dd,.table-select dl dt{padding:0 10px;line-height:36px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
    .table-select dl dd.layui-this{background-color:#5FB878;color:#fff}
    .table-select dl dd,.table-select dl dt{padding:0 10px;line-height:36px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
    .table-select dl dd:hover{background-color:#f2f2f2}

</style>
<div id="location">当前位置：首页 > 招聘方案管理 > 添加招聘方案</div>
<div id="Content">
    <form id="Validform" method="post" action="/Project/AddAction">
        <input type="hidden" id="proid" value="0"/>
        <div class="btnbar">
            <button type="submit" class="save">保 存</button>
            <button type="button" class="back" onclick="javascript:history.go(-1);">返 回</button>
        </div>
        <table class="treeTable inputform">
            <thead>
            <tr>
                <td colspan="4"><b>基本信息</b></td>
            </tr>
            </thead>
            <tbody>
            <tr>
                <td width="65">方案名称：</td>
                <td>
                    <div style="width:300px;"><input type="text" name="project.pname" datatype="*" nullmsg="方案名称不能为空！"/>
                    </div>
                </td>
            </tr>
            <tr>
                <td>招聘方式：</td>
                <td>
                    <div class="radio">
                        <span rel="1" fdata="1">高校校园招聘</span>
                        <span rel="2" fdata="2">中专校园招聘</span>
                        <span rel="3" fdata="3">社会招聘</span>
                        <span rel="4" fdata="4">内部招聘</span>
                        <input type="hidden" id="recruittype" name="project.recruittype" value="1" datatype="*"
                               nullmsg="招聘方式不能为空！">
                    </div>
                </td>
            </tr>
            </tbody>
        </table>


        <table class="layui-table" id="projectFlow" lay-data="{url:'../../resources/test/table/demo1.json',id:'projectFlows'}" lay-filter="projectFlows">
            <thead>
            <tr>
            <td colspan="9" style="background: #EEF1F8;"><b>实施流程</b></td>
            </tr>
            <tr>

                <%--<th lay-data="{type:'checkbox'}">ID</th>--%>
                <th lay-data="{field:'id', width:60, sort: false,hide: true}">ID</th>
                <th lay-data="{type:'numbers',field:'order',width:60}">顺序</th>
                <th lay-data="{field:'username', sort: false,minWidth: 80,event:'selectFlow', templet:'#comboxFlow' }">流程内容</th>
                <th lay-data="{field:'sex',  minWidth: 80 ,event:'select',templet:'#sexTpl'}">流程别名</th>
                <th lay-data="{field:'isdisplay', sort: false, templet: '#switchTpl', width: 90}">是否显示</th>
                <th lay-data="{field:'email',  edit: 'text',minWidth: 100}">预计开始日期</th>
                <th lay-data="{field:'city', edit: 'text',minWidth: 100}">预计结束日期</th>
                <th lay-data="{field:'experience', sort: false, edit: 'text'}">备注</th>
                <th lay-data="{fixed: 'right', width:120, align:'center', toolbar: '#flowTableTools'}">
                    操作
                </th>
            </tr>
            </thead>
        </table>

        <!-- 是否显示开关模板 -->
        <script type="text/html" id="switchTpl">
            <input type="checkbox" name="isdisplay" value="{{ d.LAY_TABLE_INDEX }}"  lay-skin="switch"  lay-text="是|否"  lay-filter="flowDisplay" {{ d.isdisplay == '是' ? 'checked' : '' }}>
        </script>

        <!-- 流程选择下拉菜单 -->
       <%-- <script type="text/html" id="comboxFlow">
            <select name="username" lay-filter="selectFlow" value="{{d.LAY_TABLE_INDEX}}"  >
                {{#  layui.each(d, function(index, item){ }}
                <option value="{{item.value}}">{{item.name}}</option>
                {{#  }); }}
            </select>
        </script>--%>
        <script type="text/html" id="comboxFlow">
               {{d.username}}<i class="layui-icon table-select-icon"></i>
        </script>
        <script type="text/html" id="sexTpl">
            {{d.username}}<i class="layui-icon table-select-icon"></i>
        </script>

        <%--<option value="杜甫">杜甫</option>
                      <option value="李白">李白</option>
                      <option value="王勃">王勃</option>
                      <option value="李清照">李清照</option>
                      <option value="冰心">冰心</option>
                      <option value="贤心">贤心</option>--%>

        <script type="text/html" id="flowTableTools">
            <div class="layui-btn-group">
            <a class="layui-btn layui-btn-container layui-btn-xs" lay-event="add" title="新增"><i class="layui-icon layui-icon-add-circle"></i></a>
            <a class="layui-btn layui-btn-warm layui-btn-xs layui-btn-radius" lay-event="edit" title="编辑"><i class="layui-icon layui-icon-edit"></i></a>
            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del" title="删除"><i class="layui-icon layui-icon-delete"></i></a>
            </div>
        </script>

        <table class="layui-table" lay-data="{title:'招聘岗位',url:'../../resources/test/table/jobs.json', id:'projectJobs'}" lay-filter="projectJobs">
            <thead>
            <tr style="background: #EEF1F8;">
                <td colspan="20" style="background: #EEF1F8;"><b>招聘岗位</b></td>
            </tr>
            <tr>

                <%--<th lay-data="{type:'checkbox'}">ID</th>--%>
                <th lay-data="{field:'id', width:60, sort: false,hide: true}">ID</th>
                <th lay-data="{type:'numbers',field:'order',width:60}">序号</th>
                <th lay-data="{field:'username', sort: false,minWidth: 80}">岗位名称</th>
                <th lay-data="{field:'email', minWidth: 80}">招聘人数</th>
                <th lay-data="{field:'sex',minWidth: 100}">要求年龄</th>
                <th lay-data="{field:'city', minWidth: 100}">工作年限</th>
                <th lay-data="{field:'experience', sort: false}">学历要求</th>
                <th lay-data="{field:'experience', sort: false}">专业要求</th>
                <th lay-data="{field:'experience', sort: false}">性别要求</th>
                <th lay-data="{field:'experience', sort: false}">身高要求</th>
                <th lay-data="{field:'experience', sort: false}">工作职责</th>
                 <th lay-data="{field:'experience', sort: false}">技能要求</th>
                <th lay-data="{fixed: 'right', width:120, align:'center', toolbar: '#jobsTableTools'}">
                    操作
                </th>
            </tr>
            </thead>
        </table>

        <script type="text/html" id="jobsTableTools">
            <div class="layui-btn-group">
            <a class="layui-btn layui-btn-container layui-btn-xs layui-btn-radius" lay-event="add" title="新增"><i class="layui-icon layui-icon-add-circle"></i></a>
            <a class="layui-btn layui-btn-warm layui-btn-xs layui-btn-radius" lay-event="edit" title="编辑"><i class="layui-icon layui-icon-edit"></i></a>
            <a class="layui-btn layui-btn-danger layui-btn-xs layui-btn-radius" lay-event="del" title="删除"><i class="layui-icon layui-icon-delete"></i></a>
            </div>
        </script>

    </form>
</div>
<link href="../../resources/js/plugins/layui/css/layui.css" rel="stylesheet" type="text/css"/>
<script src="../../resources/js/plugins/layui/layui.js" charset="utf-8"></script>

<script>
    var comboxdata=[{name:"杜甫",value:"杜甫"},{name:"李白",value:"李白"},{name:"王勃",value:"王勃"},{name:"李清照",value:"李清照"},{name:"冰心",value:"冰心"},{name:"贤心",value:"贤心"}];
   layui.config({
        base: '../../resources/js/plugins/layui_exts/dataTable/'
    }).use(['dataTable'], function(){

        var table = layui.dataTable
            //,dt = layui.dataTable
            ,laytpl = layui.laytpl
            ,form = layui.form;

        /*table.render({
            elem: '#projectFlows,#projectJobs'
            ,toolbar: '#jobsTableTools,#flowTableTools'
            //,…… //其他参数

        });*/
       // updateCacheOrForm("projectFlow", "projectFlows", "form");
        form.render();
       table.render({id:'#projectFlow'})


        table.on('row(projectFlows)', function(obj){
            //console.log(obj.tr) //得到当前行元素对象
            //console.log(obj.data) //得到当前行数据
            obj.tr.addClass('layui-table-click').siblings().removeClass('layui-table-click');
        });
        //监听开关操作
        form.on('switch(flowDisplay)', function(obj){
           /* console.log(obj.data);
           layer.tips(this.value + ' ' + this.name + '：'+ obj.elem.checked, obj.othis);*/
            var tablecache= table.cache['projectFlows'];
            var ck=obj.elem.checked?'是':'否';
            var changeId=this.value;
            tablecache[this.value][this.name]=ck;
            /*tablecache.each(function (index,item) {
                if(item.id==changeId){
                    item.isdisplay=ck;
                }
            })
            tablecache.update();*/
        });

            table.on('edit(flowSelect)', function(obj){

                var tablecache= table.cache['projectFlows'];
                var ck=obj.elem.checked?'是':'否';
                var changeId=this.value;
                tablecache[this.value][this.name]=ck;
            });

      /*  table.on('select(selectFlow)',function (obj) {
            table.render('#projectFlows');
            var value = obj.value //得到修改后的值
                ,data = obj.data //得到所在行所有键值
                ,field = obj.field; //得到字段
            layer.msg('[ID: '+ data.id +'] ' + field + ' 字段更改为：'+ value);
            layer.msg('[Name: '+ obj.text +']  字段更改为：'+ obj.value);
        })*/
        //监听单元格编辑
        table.on('edit(projectFlows)', function(obj){
            var value = obj.value //得到修改后的值
                ,data = obj.data //得到所在行所有键值
                ,field = obj.field; //得到字段
            layer.msg('[ID: '+ data.id +'] ' + field + ' 字段更改为：'+ value);
        });

        table.on('tool(projectFlows)', function(obj){
            var data = obj.data;
            if(obj.event === 'edit'){
                layer.alert('编辑行：<br>'+ JSON.stringify(data))
            } else if(obj.event === 'del'){

                layer.confirm('真的删除行么', function(index){
                    obj.del();
                    layer.close(index);
                });

            } else if(obj.event === 'add'){
                table.addParentRow();
                layer.confirm('确定添加流程？', {
                    title: '添加流程',
                    btn: ['确定','取消'] //按钮
                }, function(){

                }, function(){

                });
                //layer.alert('编辑行：<br>'+ JSON.stringify(data))
            }else if(obj.event == 'select'){
                table.renderTableSelect(obj,this,{
                    data:comboxdata,// select的数据
                    value:"value", // select数据中表示value的字段
                    text:"name", // select中表示显示的字段
                    valueField:"sex" , // 数据表格中表示value的字段
                    textField:"sex", // 数据表格中表示显示的字段
                });
            }else if(obj.event=='flowSelect'){
                //table.render('#projectFlows');
                //form.render('select');
                var value = obj.value //得到修改后的值
                    ,data = obj.data //得到所在行所有键值
                    ,field = obj.field; //得到字段
                layer.msg('[ID: '+ data.id +'] ' + field + ' 字段更改为：'+ value);
                layer.msg('[Name: '+ obj.text +']  字段更改为：'+ obj.value);
            }
        });

        table.on('tool(projectJobs)', function(obj){
            var data = obj.data;
            if(obj.event === 'edit'){
                layer.msg('ID：'+ data.id + ' 的查看操作');
            } else if(obj.event === 'del'){
                layer.confirm('真的删除行么', function(index){
                    obj.del();
                    layer.close(index);
                });
            } else if(obj.event === 'add'){
                layer.alert('编辑行：<br>'+ JSON.stringify(data))
            }
        });
       /* var getTpl = comboxFlow.innerHTML;
        laytpl(getTpl).render(comboxdata, function(html){
            //view.innerHTML = html;
            $('#test1').html(html);
        });
*/
        function updateCacheOrForm(tableId, tableCacheId, op){
            op = op || "form";
            var divForm = $("#" + tableId).next();
            var tableCache = table.cache[tableCacheId];
            var trJqs = divForm.find(".layui-table-body tr");
            trJqs.each(function(){
                var trJq = $(this);
                var dataIndex = trJq.attr("data-index");
                trJq.find("td").each(function(){
                    var tdJq = $(this);
                    var fieldName = tdJq.attr("data-field");
                    //var fieldName = selectJq.eq(0).attr("name");
                    //更新select数据
                    var selectJq = tdJq.find("select");
                    if(selectJq.length == 1){
                        if(op == "cache"){
                            tableCache[dataIndex][fieldName] = selectJq.eq(0).val();
                        }else if(op == "form"){
                            selectJq.eq(0).val(tableCache[dataIndex][fieldName])
                        }
                    }
                });
            });
            return tableCache;
        }


    });




</script>
<script type="text/javascript">
    var checkData;
    var jobList = [];
    $(function () {
        showJobList($('#recruittype').val());

        //选择招聘方式
        $('.radio span').click(function () {
            /*$('table[id^=flow]').hide();
            $('#flow' + $(this).attr('fdata')).show();*/
            checkData = $(this).attr('fdata');
            showJobList($(this).attr('fdata'));
            fillFlows($(this).attr('fdata'));
        });

        $('#flows button.add').click(function () {
            if (checkData == 2) {

                var temp = '<tr><td>2</td><td><div><select name="flow[1].fid"><option value="1">初审</option><option value="2">面试</option><option value="4">背景调查</option><option value="5">体检</option><option value="7">实习</option></select></div></td>';
                temp += '<td><div><input type="text" name="flow[1].nickname" datatype="*" nullmsg="流程别名不能为空！"></div></td>';
                temp += '<td><div><input type="text" name="flow[1].starttime" ></div></td>'
                temp += '<td><div><input type="text" name="flow[1].endtime" ></div></td>'
                temp += '<td><div><textarea name="flow[1].remark"></textarea></div></td>'
                temp += '<td><button type="button" onfocus="blur()" class="del"></button></td></tr>';

                $('#flows tbody tr:last').before(temp);
                $('#flows tbody tr:last').prev().find('td:eq(2) input').val($('#flows tbody tr:last').prev().find('td:eq(1) select option:checked').text());
                setFlowStyle();
            } else
            if (checkData == 1 || checkData == 3) {

                var temp = '<tr><td>2</td><td><div><select name="flow[1].fid"><option value="1">笔试</option><option value="2">资料审核</option><option value="3">面试</option><option value="4">实作</option><option value="5">体检</option><option value="6">背景调查</option></select></div></td>';
                temp += '<td><div><input type="text" name="flow[1].nickname" datatype="*" nullmsg="流程别名不能为空！"></div></td>';
                temp += '<td><div><input type="text" name="flow[1].starttime" ></div></td>'
                temp += '<td><div><input type="text" name="flow[1].endtime" ></div></td>'
                temp += '<td><div><textarea name="flow[1].remark"></textarea></div></td>'
                temp += '<td><button type="button" onfocus="blur()" class="del"></button></td></tr>';

                $('#flows tbody tr:last').before(temp);
                $('#flows tbody tr:last').prev().find('td:eq(2) input').val($('#flows tbody tr:last').prev().find('td:eq(1) select option:checked').text());
                setFlowStyle();
            } else if (checkData == 4) {
                var temp = '<tr><td>2</td><td><div><select name="flow[1].fid"><option value="2">面试</option><option value="3">笔试</option></select></div></td>';
                temp += '<td><div><input type="text" name="flow[1].nickname" value="面试" datatype="*" nullmsg="流程别名不能为空！"></div></td>';
                temp += '<td><div><input type="text" name="flow[1].starttime" ></div></td>'
                temp += '<td><div><input type="text" name="flow[1].endtime" ></div></td>'
                temp += '<td><div><textarea name="flow[1].remark"></textarea></div></td>'
                temp += '<td><button type="button" onfocus="blur()" class="del"></button></td></tr>';

                $('#flows tbody tr:last').before(temp);
                setFlowStyle();
            } else {
                layer.msg('请先选择招聘方案的种类!', {
                    time: 5000, //5s后自动关闭
                    icon: 2
                });

            }

        });


        //删除流程
        $(document).delegate('#flows button.del', 'click', function () {
            $(this).parent().parent().remove();
            setFlowStyle();
        });

        //流程别名
        $(document).delegate('#flows select', 'change', function () {
            $(this).parent().parent().next().find('input').val($(this).find('option:checked').text());
            $(this).prev().val($(this).val());
        });

        //添加招聘岗位
        $('#jobtb button.add').click(function () {
            openLayer('添加招聘岗位', '/Project/AddJobByWeb?pid=${project.id}&ptype='+$('#recruittype').val(), '98%', '98%');
        });

        //删除招聘岗位
        $(document).delegate('#jobtb button.del', 'click', function () {
            var _obj = $(this);
            layer.confirm('确定要删除该岗位吗？', {
                btn: ['是', '否']
            }, function () {
                var row = _obj.parent().parent();
                var rowNum = $(row).index();
                jobList = jobList.slice(0, rowNum).concat(jobList.slice(rowNum + 1, jobList.length))
                //_obj.parent().parent().remove();
                fullJobList();
                layer.closeAll();
            }, function () {
                layer.closeAll();
            });
        });

        //修改招聘岗位
        $(document).delegate('#jobtb button.edit', 'click', function () {
            var _obj = $(this);
            var row = _obj.parent().parent();
            var rowNum = $(row).index();
            var url = '/Project/EditJobByWeb?id=' + rowNum+'&ptype='+$('#recruittype').val();
            openLayer('修改招聘岗位', url, '98%', '98%');
        });

        //删除招聘岗位
        $(document).delegate('#jobtb button.del', 'click', function () {
            $(this).parent().parent().remove();
            setJobStyle();
        });

        //招聘地区
        $(document).delegate('.inputform tbody div.radio1 span', 'click', function () {
            $(this).parent().find('input[type=hidden]').remove();
            if (!$(this).parent().hasClass('disables')) {
                if ($(this).hasClass('checked'))
                    $(this).removeClass('checked');
                else
                    $(this).addClass('checked');
                var i = 0;
                $(this).parent().find('span').each(function () {
                    if ($(this).hasClass('checked')) {
                        $(this).parent().append('<input type="hidden" name="region[' + i + '].rcode" value="' + $(this).attr('rel') + '" />');
                        $(this).parent().append('<input type="hidden" name="region[' + i + '].region" value="' + $(this).text() + '" />');
                        i++;
                    }
                });
            }
        });

        $('.radio span:first').click();
    });

    function fillFlows(data) {
        var temp = '';
        switch (parseInt(data)) {
            case 1:
                temp = createGXFlow();
                break;
            case 2:
                temp = createZZFlow();
                //temp = createGXFlow();
                break;
            case 3:
                temp = createSZFlow();
                break;
            case 4:
                temp = createNBFlow();
                break;
            default:
                break;
        }
        $('#flows tbody').empty();
        $('#flows tbody').append(temp);
        setFlowStyle();
    }

    //初始社招招聘流程
    function createSZFlow() {
        var temp = '<tr>'
            + ' <td>1</td>'
            + ' <td>简历筛选<input type="hidden" name="flow[0].fid" value="0"/></td>'
            + '     <td>简历筛选<input type="hidden" name="flow[0].nickname" value="简历筛选"/></td>'
            + '<td><div><input type="text" name="flow[0].starttime" ></div></td>'
            + '<td><div><input type="text" name="flow[0].endtime" ></div></td>'
            + '<td><div><textarea name="flow[0].remark"></textarea></div></td>'
            + '  <td></td>'
            + '  </tr>'
            + '    <tr>'
            + '    <td>2</td>'
            + '     <td>录用<input type="hidden" name="flow[1].fid" value="7"/></td>'
            + '    <td>录用<input type="hidden" name="flow[1].nickname" value="录用"/></td>'
            + '<td><div><input type="text" name="flow[1].starttime" ></div></td>'
            + '<td><div><input type="text" name="flow[1].endtime" ></div></td>'
            + '<td><div><textarea name="flow[1].remark"></textarea></div></td>'
            + '  <td></td>'
            + ' </tr> ';
        /* var temp = '<tr><td>2</td><td><div><select name="flow[1].fid"><option value="1">笔试</option><option value="2">资料审核</option><option value="3">面试</option><option value="4">实作</option><option value="5">体检</option><option value="6">背景调查</option></select></div></td>';
         temp += '<td><div><input type="text" name="flow[1].nickname" datatype="*" nullmsg="流程别名不能为空！"></div></td>';
         temp += '<td><button type="button" onfocus="blur()" class="del"></button></td></tr>';*/
        return temp;
    }

    //初始中专招聘流程
    function createZZFlow() {

        var temp = '<tr>\n' +
            '                <td>1</td>\n' +
            '                <td>毕业生推荐<input type="hidden" name="flow[0].fid" value="0"/></td>\n' +
            '                <td>毕业生推荐<input type="hidden" name="flow[0].nickname" value="毕业生推荐"/></td>\n' +
            + '<td><div><input type="text" name="flow[0].starttime" ></div></td>'
            + '<td><div><input type="text" name="flow[0].endtime" ></div></td>'
            + '<td><div><textarea name="flow[0].remark"></textarea></div></td>'
            '                <td></td>\n' +
            '            </tr>\n' +
            '            <tr>\n' +
            '                <td>4</td>\n' +
            '                <td>录用<input type="hidden" name="flow[1].fid" value="8"/></td>\n' +
            '                <td>录用<input type="hidden" name="flow[1].nickname" value="录用"/></td>\n' +
            + '<td><div><input type="text" name="flow[0].starttime" ></div></td>'
            + '<td><div><input type="text" name="flow[0].endtime" ></div></td>'
            + '<td><div><textarea name="flow[0].remark"></textarea></div></td>'
            '                <td></td>\n' +
            '            </tr>';
        return temp;
    }

    //初始高校招聘流程
    function createGXFlow() {
        /* var temp='<tr>\n' +
             '                <td>1</td>\n' +
             '                <td>简历筛选<input type="hidden" name="flow[0].fid" value="0"/></td>\n' +
             '                <td>简历筛选<input type="hidden" name="flow[0].nickname" value="简历筛选"/></td>\n' +
             '                <td></td>\n' +
             '            </tr>\n' +
             '            <tr>\n' +
             '                <td>2</td>\n' +
             '                <td>面试<input type="hidden" name="flow[1].fid" value="1"/></td>\n' +
             '                <td>面试<input type="hidden" name="flow[1].nickname" value="面试"/></td>\n' +
             '                <td><button type="button" onfocus="blur()" class="del"></button></td>\n' +
             '            </tr>\n' +
             '            <tr>\n' +
             '                <td>3</td>\n' +
             '                <td>背景调查<input type="hidden" name="flow[1].fid" value="2"/></td>\n' +
             '                <td>背景调查<input type="hidden" name="flow[1].nickname" value="背景调查"/></td>\n' +
             '                <td><button type="button" onfocus="blur()" class="del"></button></td>\n' +
             '            </tr>\n' +
             '            <tr>\n' +
             '                <td>4</td>\n' +
             '                <td>体检<input type="hidden" name="flow[1].fid" value="3"/></td>\n' +
             '                <td>体检<input type="hidden" name="flow[1].nickname" value="体检"/></td>\n' +
             '                <td><button type="button" onfocus="blur()" class="del"></button></td>\n' +
             '            </tr>\n' +
             '            <tr>\n' +
             '                <td>5</td>\n' +
             '                <td>岗位分配<input type="hidden" name="flow[1].fid" value="4"/></td>\n' +
             '                <td>岗位分配<input type="hidden" name="flow[1].nickname" value="岗位分配"/></td>\n' +
             '                <td><button type="button" onfocus="blur()" class="del"></button></td>\n' +
             '            </tr>\n' +
             '            <tr>\n' +
             '                <td>6</td>\n' +
             '                <td>录用<input type="hidden" name="flow[1].fid" value="5"/></td>\n' +
             '                <td>录用<input type="hidden" name="flow[1].nickname" value="录用"/></td>\n' +
             '                <td></td>\n' +
             '            </tr>';*/

        var temp = '<tr>'
            + ' <td>1</td>'
            + ' <td>简历筛选<input type="hidden" name="flow[0].fid" value="0"/></td>'
            + '     <td>简历筛选<input type="hidden" name="flow[0].nickname" value="简历筛选"/></td>'
            + '<td><div><input type="text" name="flow[0].starttime" ></div></td>'
            + '<td><div><input type="text" name="flow[0].endtime" ></div></td>'
            + '<td><div><textarea name="flow[0].remark"></textarea></div></td>'
            + '  <td></td>'
            + '  </tr>'
            + '            <tr>'
            + '                <td>2</td>'
            + '                <td>面试<input type="hidden" name="flow[1].fid" value="3"/></td>'
            + '                <td>面试<input type="hidden" name="flow[1].nickname" value="面试"/></td>'
            + '<td><div><input type="text" name="flow[1].starttime" ></div></td>'
            + '<td><div><input type="text" name="flow[1].endtime" ></div></td>'
            + '<td><div><textarea name="flow[1].remark"></textarea></div></td>'
            + '                <td><button type="button" onfocus="blur()" class="del"></button></td>'
            + '            </tr>'

            + '            <tr>'
            + '                <td>3</td>'
            + '                <td>体检<input type="hidden" name="flow[2].fid" value="5"/></td>'
            + '                <td>体检<input type="hidden" name="flow[2].nickname" value="体检"/></td>'
            + '<td><div><input type="text" name="flow[2].starttime" ></div></td>'
            + '<td><div><input type="text" name="flow[2].endtime" ></div></td>'
            + '<td><div><textarea name="flow[2].remark"></textarea></div></td>'
            + '                <td><button type="button" onfocus="blur()" class="del"></button></td>'
            + '            </tr>'
            + '           <tr>'
            + '                <td>4</td>'
            + '                <td>背景调查<input type="hidden" name="flow[3].fid" value="6"/></td>'
            + '                <td>背景调查<input type="hidden" name="flow[3].nickname" value="背景调查"/></td>'
            + '<td><div><input type="text" name="flow[3].starttime" ></div></td>'
            + '<td><div><input type="text" name="flow[3].endtime" ></div></td>'
            + '<td><div><textarea name="flow[3].remark"></textarea></div></td>'
            + '                <td><button type="button" onfocus="blur()" class="del"></button></td>'
            + '            </tr>'
            + '    <td>5</td>'
            + '     <td>录用<input type="hidden" name="flow[4].fid" value="7"/></td>'
            + '    <td>录用<input type="hidden" name="flow[4].nickname" value="录用"/></td>'
            + '<td><div><input type="text" name="flow[4].starttime" ></div></td>'
            + '<td><div><input type="text" name="flow[4].endtime" ></div></td>'
            + '<td><div><textarea name="flow[4].remark"></textarea></div></td>'
            + '  <td></td>'
            + ' </tr> ';
        return temp;
    }

    //初始内部招聘流程
    function createNBFlow() {
        var temp = '<tr>\n' +
            '                <td>1</td>\n' +
            '                <td>职位申请<input type="hidden" name="flow[0].fid" value="0"/></td>\n' +
            '                <td>职位申请<input type="hidden" name="flow[0].nickname" value="职位申请"/></td>\n' +
            '                <td></td>\n' +
            '            </tr>\n' +
            '            <tr>\n' +
            '                <td>2</td>\n' +
            '                <td>简历筛选<input type="hidden" name="flow[1].fid" value="1"/></td>\n' +
            '                <td>简历筛选<input type="hidden" name="flow[1].nickname" value="简历筛选"/></td>\n' +
            '                <td></td>\n' +
            '            </tr>\n' +
            '            <tr>\n' +
            '                <td>3</td>\n' +
            '                <td>录用<input type="hidden" name="flow[2].fid" value="4"/></td>\n' +
            '                <td>录用<input type="hidden" name="flow[2].nickname" value="录用"/></td>\n' +
            '                <td></td>\n' +
            '            </tr>'

        return temp;
    }

    //设置流程表单信息
    function setFlowStyle() {

        $('#flows tbody tr').each(function (index) {
            $(this).find('td:first').html(index + 1);
            if (index > 1 && index < $('#flows tbody tr').length - 1) {
                $(this).find('td:eq(1) select').attr('name', 'flow[' + index + '].fid');
                $(this).find('td:eq(2) input').attr('name', 'flow[' + index + '].nickname');
            } else {
                $(this).find('td:eq(1) input').attr('name', 'flow[' + index + '].fid');
                $(this).find('td:eq(2) input').attr('name', 'flow[' + index + '].nickname');
            }
        });


    }

    //设置岗位表单信息
    function setJobStyle() {
        $('#result tr').each(function (index) {
            $(this).find('td:first span').html(index + 1);
            $(this).find('td:first input').attr('name', 'job[' + index + '].did');
            $(this).find('td:eq(8) input').attr('name', 'job[' + index + '].zpcount');
        });
    }

    //显示或隐藏岗位列表
    function showJobList(str) {
        $('#jobtb').hide();
        $('#areagx').hide();
        /*if (str == '2') {
            $('#areagx').show();
        } else {
            $('#jobtb').show();
        }*/
        $('#jobtb').show();
    }

    //添加职位列表
    function fullJobList() {
        if (jobList.length > 0) {
            $("#jobtb tbody").empty();
            for (var i = 0; i < jobList.length; i++) {
                var job = jobList[i];
                var tr = $("<tr></tr>");
                tr.append($("<td>" + (i + 1) + "</td>"));
                tr.append($("<td>" + job.jobname + "</td>"));
                tr.append($("<td>" + job.zpcount + "</td>"))
                if (job.agef == null || job.aget == null) {
                    tr.append("<td>不限</td>");
                } else {
                    tr.append("<td>" + job.agef + "-" + job.aget + "</td>");
                }
                if (job.workyear == null || job.workyear.length == 0) {
                    tr.append("<td>不限</td>");
                } else {
                    tr.append("<td>" + job.workyear + "年以上</td>");
                }
                tr.append("<td>" + job.eduname + "</td>");
                if (job.major == null || job.major.length == 0) {
                    tr.append("<td>不限</td>");
                } else {
                    tr.append("<td>" + job.major + "</td>");
                }
                tr.append("<td>" + job.gender + "</td>");
                var ctd = $("<td></td>");
                ctd.append("<button type='button' onfocus='blur()' class='edit' id='edit_job_" + i + "'></button>");
                /* ctd.append("<input type='hidden'  value='" + i + "'>");
                 ctd.append("<input type='hidden'  value='" + job.istemplate + "'>");
                 ctd.append("<input type='hidden' value='" + job.required + "'>");
                 ctd.append("<input type='hidden' value='" + job.workreq + "'>");*/
                ctd.append("<button type='button' onfocus='blur()' class='del' id='del_job_\"+i+\"'></button>");
                tr.append(ctd);
                $("#jobtb tbody").append(tr);

            }
            var jss = JSON.stringify(jobList);
            $("#jobsList").val(jss);
        }
    }
</script>
</body>
</html>